﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SmallERP.MODEL.FoundationModel;
using SmallERP.Bll;
using SmallERP.DAL;


namespace SmallERP.Bll.CutBoard
{
    public  class CutBoardBLL
    {
        public Board_Info GetBoardInfo(int boardId)
        {
            Board_Info boardInfo =null;
            using (smallerpDataContext db = new smallerpDataContext())
            {
                Board board = db.Board.FirstOrDefault(b => b.BoardId == boardId);
                if (board != null)
                {
                    boardInfo = new Board_Info()
                    {
                        AutoPoint = board.AutoPoint,
                        BoardId = board.BoardId,
                        CreateTime = board.CreateTime,
                        DPI = board.DPI,
                        Height = board.Height,
                        LastPrintTime = board.LastPrintTime,
                        Length = board.Length,
                        PicPath = board.picPath,
                        PrinterId = board.PrinterId,
                        Status = board.Status
                    };
                }
            }
            return boardInfo;
 
        }

        public Printer_info GetPrinterInfo(int printerId)
        {
            Printer_info printerInfo = null;
            using (smallerpDataContext db = new smallerpDataContext())
            {
                printer printer = db.printer.FirstOrDefault(p=>p.PrinterID==printerId);
                if (printer != null)
                {
                    printerInfo = new Printer_info()
                    {
                      PrinterID =printer.PrinterID,
                      CalibrationData=printer.CalibrationData,
                      IsTransverse =printer.IsTransverse
                    };
                }
            }
            return printerInfo;
        }

        /// <summary>
        /// 裁切大板
        /// </summary>
        /// <param name="PointString"></param>
        /// <param name="CoordinateString"></param>
        /// <param name="RotatePrint"></param>
        /// <returns></returns>
        public  string VectorPointToMachine(string PointString, string CoordinateString, bool RotatePrint)
        {
            string result = string.Empty;
            Machine  mac = new Machine();
            result = mac.VectorPointToMachine(PointString, CoordinateString, RotatePrint);
            mac.Dispose();
            return result;
           
        }

        /// <summary>
        /// 判断裁切机器是否忙
        /// </summary>
        /// <returns></returns>
        public virtual bool isMachineBusy()
        {
            bool result = false;
            Machine mac = new Machine();
            result = mac.isMachineBusy();
            mac.Dispose();
            return result;
        }

    }
}
